package com.jeff.springWebTestNG.infinispan.listeners;

import org.infinispan.notifications.Listener;
import org.infinispan.notifications.cachelistener.annotation.CacheEntryCreated;
import org.infinispan.notifications.cachelistener.annotation.CacheEntryEvicted;
import org.infinispan.notifications.cachelistener.event.CacheEntryCreatedEvent;
import org.infinispan.notifications.cachelistener.event.CacheEntryEvictedEvent;

// no idea why each doSthxx method will be triggered twice
@Listener(sync = false)
public class OneAsyncListener {
	@CacheEntryCreated
	public void doSthOnCreation(CacheEntryCreatedEvent event) {
		System.out.println("An entry with key: " + event.getKey() + " was added to cache: " + event.getCache().getName());
//		System.out.println("Creation done");
	}
	
	@CacheEntryEvicted
	public void doSthOnEviction(CacheEntryEvictedEvent event) {
		System.out.println("An entry with key: " + event.getKey() + " was evicted from cache: " + event.getCache().getName());
	}
}
